# coding:utf-8
import jieba

from script.filter import filter_words
from script.mysql_lib import MysqlBase

model_tag = MysqlBase('content')

sql = model_tag.select_tpl(['title', 'content'])
word = model_tag.query(sql)

word_list = []
for row in word:
    word_list.extend(
        jieba.cut_for_search(row['title'])
    )
    word_list.extend(
        jieba.cut_for_search(row['content'])
    )

with open('../dic_text/content.txt', 'w', encoding='utf-8') as f:
    f.write('\n'.join(filter_words(word_list, 10, only_cn=True)))
